package cn.kshost.zqyg.service.pay.controller;

import cn.kshost.zqyg.model.vo.common.Result;
import cn.kshost.zqyg.model.vo.common.ResultCodeEnum;
import cn.kshost.zqyg.service.pay.service.AliPayService;
import io.swagger.v3.oas.annotations.Operation;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/order/alipay")
public class AliPayController {
    @Autowired
    private AliPayService aliPayService;
    @Operation(summary = "通过订单id发起支付")
    @GetMapping("/submitAlipay/{orderId}")
    public Result<String> submitAlipay(@PathVariable("orderId") String orderId) {
       String body =  aliPayService.submitAlipay(orderId);
       return  Result.build(body, ResultCodeEnum.SUCCESS);
    }
    @Operation(summary = "支付宝支付成功回调")
    @PostMapping("/callback/notify")
    public String callbackNotify(HttpServletRequest request) {
    String result =  aliPayService.callbackNotify(request);
    return  result;
    }
}
